//
//  SDLoginViewController.m
//  SKinDiary
//
//  Created by pcyang on 16/7/10.
//  Copyright © 2016年 tencent. All rights reserved.
//

#import "SDLoginViewController.h"
#import "SDLoginData.h"
#import "SDLoginManager.h"


@implementation SDLoginViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginDidFailNotification:) name:kLoginServiceeDidFailNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginDidSuccessNotification:) name:kLoginMgrDidSucceedNotificaion object:nil];
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear: animated];
}

-(BOOL)navigationBarHidden
{
    return NO;
}

-(void)initData
{
}

-(void)initSubviews
{
    [super initSubviews];
    
    BOOL naviHidden = [self navigationBarHidden];
    if (!naviHidden && self.navBar != nil)
    {
        [self.navBar setTitle:@""];
        UIImage* backImg = LOAD_IMAGE_USE_CACHE_INBUNDLE(DefaultBundle, @"actionbar_btn_back.png");
        [self.navBar customNaviLeftButton:self action:@selector(onBack:) image:backImg];
    }
    
}

-(BOOL)skipButtonHidden
{
    return YES;
}

- (void)onBack:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
    
}


-(void)animateTextField:(UITextField*)textField up:(BOOL)up
{
    const int movementDistance = -100;
    const float movementDuration = 0.3f;
    
    int movement = (up ? movementDistance : -movementDistance);
    
    [UIView beginAnimations: @"animateTextField" context: nil];
    [UIView setAnimationBeginsFromCurrentState: YES];
    [UIView setAnimationDuration: movementDuration];
    self.view.frame = CGRectOffset(self.view.frame, 0, movement);
    [UIView commitAnimations];
}


#pragma mark -
#pragma mark -  Login Notifications
- (void)loginDidSuccessNotification:(NSNotification *)not
{
    [self onBack:nil];
}

- (void)loginDidFailNotification:(NSNotification *)not
{
    
}

@end
